package com.jzy.shardingjdbc.service.impl;

import com.jzy.shardingjdbc.entity.GoodInfo;
import com.jzy.shardingjdbc.entity.User;
import com.jzy.shardingjdbc.repository.UserRepository;
import com.jzy.shardingjdbc.service.UserService;
import io.shardingsphere.api.HintManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author jinzhiyuan
 * @Description:
 * @date 2020-4-28 17:35
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserRepository userRepository;

    @Override
    public Integer addUser(User user) {
        // 强制路由主库
//        HintManager.getInstance().setMasterRouteOnly();
        return userRepository.addUser(user);
    }

    @Override
    public List<User> list() {
        return userRepository.list();
    }

    @Override
    public int addGoods(GoodInfo goodInfo) {
        return userRepository.addGoods(goodInfo);
    }

    @Override
    public List<GoodInfo> getGoodList() {
        return userRepository.getGoodList();
    }
}
